package com.betterjr.modules.risk.loanmanage;

import static com.betterjr.common.web.ControllerExceptionHandler.exec;

import java.util.Map;

import javax.servlet.http.HttpServletRequest;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import com.alibaba.dubbo.config.annotation.Reference;
import com.betterjr.common.web.Servlets;

@Controller
@RequestMapping("/Scf/Partnership")
public class PartnershipController {

    private static final Logger logger = LoggerFactory.getLogger(PartnershipController.class);

    @Reference(interfaceClass = IPartnershipService.class)
    private IPartnershipService partnershipService;

    @RequestMapping(value = "/savePartnership", method = RequestMethod.POST)
    public @ResponseBody String savePartnership(final HttpServletRequest request) {
        logger.info("保存合作关系数据");
        final Map<String, Object> param = Servlets.getParametersStartingWith(request, "");
        return exec(() -> partnershipService.savePartnership(param), "保存合作关系数据失败", logger);

    }

    @RequestMapping(value = "/queryPartnershipByPage", method = RequestMethod.POST)
    public @ResponseBody String queryPartnershipByPage(final HttpServletRequest request, final int pageNum,
            final int pageSize, final String flag) {
        logger.info("分页合作关系数据");
        final Map<String, Object> param = Servlets.getParametersStartingWith(request, "");
        return exec(() -> partnershipService.listPartnershipByPage(param, pageNum, pageSize, null), "分页合作关系数据失败",
                logger);

    }

    @RequestMapping(value = "/queryPartnership", method = RequestMethod.POST)
    public @ResponseBody String queryPartnershipByPage(final HttpServletRequest request) {
        logger.info("查询合作关系数据");
        final Map<String, Object> param = Servlets.getParametersStartingWith(request, "");
        return exec(() -> partnershipService.listPartnership(param), "查询关系数据失败", logger);

    }

}
